package edu.sctu.zhu.dao;

import edu.sctu.zhu.bean.MyIndex;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Created by zhu on 2016/2/6.
 */
@Repository
@Transactional
public interface MyIndexDao extends CrudRepository<MyIndex,Long>{


    @Query(value = "SELECT * FROM my_index WHERE purpose =? ORDER BY heat DESC",nativeQuery = true)
    public List<MyIndex> findByUserDesc(String use);

    @Modifying(clearAutomatically = true)
    @Query(value = "UPDATE my_index SET goods_id=? WHERE id=? ",nativeQuery = true)
    public void upadateGoodsId(Long goodsId,Long id);

    @Modifying(clearAutomatically = true)
    @Query(value = "UPDATE my_index SET heat=?,goods_id=? WHERE id=? ",nativeQuery = true)
    public void upadateHeat(int heat,Long goodsId,Long id);
}
